# -*- coding: utf-8 -*-
# @Author  : pony.guan
# @Time    : 2021/10/18
# Description:

import socket
import requests


def get_local_ip():
    """
    获取本地ipv4地址
    """
    try:
        csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        csock.connect(('8.8.8.8', 80))
        addr, port = csock.getsockname()
        csock.close()
        return addr
    except socket.error:
        return "127.0.0.1"

print(get_local_ip())